<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: bobo
  Date: 16-11-4
  Time: 上午11:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <jsp:include page="../layout/head.jsp" >
        <jsp:param name="title" value="" />
    </jsp:include>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 举报信息</strong></div>
    <div class="cm">
        留言ID:${message.id}<br>
        发表人：${message.user.name}<br>
        发表时间:${message.createTime}<br>
        内容：${message.content}<br>
        禁用<input type="radio" class="${message.id}" name="${message.id}status" value="0" ${message.status ==0 ?"checked":""} onchange="radioValue(this)">
        启用<input type="radio" class="${message.id}" name="${message.id}status" value="1" ${message.status ==1 ?"checked":""} onchange="radioValue(this)">
        屏蔽<input type="radio" class="${message.id}" name="${message.id}status" value="2" ${message.status ==2 ?"checked":""} onchange="radioValue(this)">
        <button onclick="cu(${message.user.id})">禁言</button>
        <br>
    </div>

    <table class="table table-hover text-center">
        <tr>
            <th>举报人</th>
            <th>内容</th>
            <th width="25%">举报时间</th>
        </tr>
        <c:forEach items="${page.list}" var="report" varStatus="abc">
            <tr>
                <td>${report.user.name}</td>
                <td>${report.content}</td>
                <td>${report.createTime}</td>
            </tr>
        </c:forEach>
        <tr>
        <td colspan="5">
            <form action="${pageContext.request.contextPath}/admin/report/getReport" method="get" id="headerImg">
                <input type="hidden" name="messageId" value="${message.id}">
            <ul class="pagelist">
            <li><span>共${page.pageNum}页</span></li>
            <li><a href="${pageContext.request.contextPath}/admin/report/getReport?messageId=${message.id}&current=1&pageSize=${page.pageSize}">首页</a></li>
            <li><a href="${pageContext.request.contextPath}/admin/report/getReport?messageId=${message.id}&current=${(page.current - 1 ) <= 0 ? 1 : (page.current - 1) }&pageSize=${page.pageSize}">上一页 </a> </li>
            <li><span>当前第${page.current}页</span></li>
            <li><a href="${pageContext.request.contextPath}/admin/report/getReport?messageId=${message.id}&current=${page.current + 1 > page.pageNum ? page.pageNum  : headers.current + 1   }&pageSize=${page.pageSize}">下一页 </a></li>
            <li><a href="${pageContext.request.contextPath}/admin/report/getReport?messageId=${message.id}&current=${page.pageNum}&pageSize=${page.pageSize}">尾页</a></li>
            <li><span>每页</span>
            <select name="pageSize" id="changePageSize" >
            <option value="1" ${page.pageSize == 1 ? "selected" :''} >1</option>
            <option value="2" ${page.pageSize == 2 ? "selected" :''} >2</option>
            <option value="5" ${page.pageSize == 5 ? "selected" :''}  >5</option>
            </select>条记录
            </li>
            <li><span>跳转至第</span><input type="number" name="current" min="1" max="${page.pageNum}"><span>页</span></li>
            <li><input class="button-sub" type="submit" value="跳转"></li>
            </ul>
            </form>
        </td>
        </tr>
    </table>
</div>
<script>
    $("#changePageSize").change(function () {
        $("input[name='current']").val(1);
        $("#pageForm").submit();
    });
</script>
<script>
    function cu(id) {
        $.ajax({
            url:"${pageContext.request.contextPath}/admin/user/changeStatus",
            type:"get",
            data:{"id":id,"status":0},
            success : function (data) {
                if(data == "true"){
                    alert("修改成功");
                }
            },
            error:function () {
                alert("失败");
            }
        })
    }

    function radioValue(node) {
        $.ajax({
            url: "${pageContext.request.contextPath}/admin/message/changeStatus",
            type: "get",
            data: {"id": node.className, "status": node.value},
            success:function (data) {
                if(data == "true") {
                    alert("修改成功");
                }
            },
            error: function () {
                alert("修改失败");
            }
        })
    }
</script>
</body>
</html>
